package org.smart4j.framework.aspect;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.smart4j.framework.annotation.Aspect;
import org.smart4j.framework.annotation.Controller;
import org.smart4j.framework.proxy.AspectProxy;

import java.lang.reflect.Method;

/**
 * Created by Wenxin on 2017/3/3.
 */
@Aspect(Controller.class)
public class ControllerAspect extends AspectProxy {

    private static final Logger LOGGER = LoggerFactory.getLogger(ControllerAspect.class);

    @Override
    public void before(Class<?> cls, Method method, Object[] params) throws Throwable {
        LOGGER.debug("class: {}", cls.getName());
        LOGGER.debug("method: {}", method.getName());
    }

    @Override
    public void begin() {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("-----------------------------------Controller begin-----------------------------------------");
        }
    }

    @Override
    public void end() {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("-----------------------------------Controller end-------------------------------------------");
        }
    }
}
